package com.hzncc.flowable_diboot.payment.dto;

import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.hzncc.flowable_diboot.payment.entity.SapPaymentContract;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
* sap合同收款 DTO定义
*
* @author MyName
* @version 1.0
* @date 2024-10-29
 * Copyright © MyCorp
*/
@Getter
@Setter
@Accessors(chain = true)
public class SapPaymentContractDTO extends SapPaymentContract  {
    private static final long serialVersionUID = 1596407333232476617L;

    @BindQuery(ignore = true)
    private String mustContractCode;

    @BindQuery(ignore = true)
    private String mustSapContractCode;

    /**
    * id集合
    */
    @BindQuery(comparison = Comparison.IN, field = "id")
    private List<String> ids;

    /**
    * 开票金额 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "invoicedAmount")
    private BigDecimal invoicedAmountBegin;

    /**
    * 开票金额 截止
    */
    @BindQuery(comparison = Comparison.LE, field = "invoicedAmount")
    private BigDecimal invoicedAmountEnd;

    /**
    * 合同金额 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "totalAmount")
    private BigDecimal totalAmountBegin;

    /**
    * 合同金额 截止
    */
    @BindQuery(comparison = Comparison.LE, field = "totalAmount")
    private BigDecimal totalAmountEnd;

    /**
    * 本次收款金额 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "currentCollectionAmount")
    private BigDecimal currentCollectionAmountBegin;

    /**
    * 本次收款金额 截止
    */
    @BindQuery(comparison = Comparison.LE, field = "currentCollectionAmount")
    private BigDecimal currentCollectionAmountEnd;

    /**
    * 已收款金额 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "receivedAmount")
    private BigDecimal receivedAmountBegin;

    /**
    * 已收款金额 截止
    */
    @BindQuery(comparison = Comparison.LE, field = "receivedAmount")
    private BigDecimal receivedAmountEnd;

    /**
    * 未收款金额 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "unpaidAmount")
    private BigDecimal unpaidAmountBegin;

    /**
    * 未收款金额 截止
    */
    @BindQuery(comparison = Comparison.LE, field = "unpaidAmount")
    private BigDecimal unpaidAmountEnd;

    /**
    * 开票日期
    */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime invoicedTime;

    /**
    * 开票日期 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "invoicedTime")
    private LocalDate invoicedTimeBegin;

    /**
    * 开票日期 截止
    */
    @BindQuery(comparison = Comparison.LT, field = "invoicedTime")
    private LocalDate invoicedTimeEnd;

    /**
    * 创建时间
    */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime createTime;

    /**
    * 创建时间 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "createTime")
    private LocalDate createTimeBegin;

    /**
    * 创建时间 截止
    */
    @BindQuery(comparison = Comparison.LT, field = "createTime")
    private LocalDate createTimeEnd;

    /**
    * 更新时间
    */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime updateTime;

    /**
    * 更新时间 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "updateTime")
    private LocalDate updateTimeBegin;

    /**
    * 更新时间 截止
    */
    @BindQuery(comparison = Comparison.LT, field = "updateTime")
    private LocalDate updateTimeEnd;

    public LocalDate getInvoicedTimeEnd() {
        if (getInvoicedTime() != null) {
            return getInvoicedTime().plusDays(1).toLocalDate();
        }
        if (invoicedTimeEnd != null) {
            return invoicedTimeEnd.plusDays(1);
        }
        return null;
    }

    public LocalDate getCreateTimeEnd() {
        if (getCreateTime() != null) {
            return getCreateTime().plusDays(1).toLocalDate();
        }
        if (createTimeEnd != null) {
            return createTimeEnd.plusDays(1);
        }
        return null;
    }

    public LocalDate getUpdateTimeEnd() {
        if (getUpdateTime() != null) {
            return getUpdateTime().plusDays(1).toLocalDate();
        }
        if (updateTimeEnd != null) {
            return updateTimeEnd.plusDays(1);
        }
        return null;
    }

}